import unittest
from human import Player
from human import Enemy
from tmap import Map
class BtTest(unittest.TestCase):
    def setUp(self):
        self.ppl=Player(mhp=10,hp=10)
        self.e=Enemy(mhp=7,hp=7)
        self.newmap=Map([[self.e,self.ppl]])
    def test_hitbang(self):
        self.newmap.missionStart()
        self.newmap.mapRoundStart()
        self.ppl.attack(self.e,bang=1)
        self.assertEqual(self.e.hp,-3)

    def test_cri(self):
        c=0     
        self.newmap.missionStart()
        for i in range(0,1000):
            self.newmap.mapRoundStart()
            hp,b=self.ppl.attack(self.e)
            if b:
                self.assertNotEqual(self.e.hp,3)
                c=c+1
            else:
                self.assertEqual(self.e.hp<=2,True)
            self.e.hp=7
        print c
        self.assertEqual(c>=30,True)
        self.assertEqual(c<=70,True)

if __name__== '__main__':
    unittest.main()

                
                
